vue element 的el

您所在的位置:网站首页 element ui 弹出层 vue element 的el

vue element 的el

2023-11-05 01:58| 来源: 网络整理| 查看: 265

vue的爬坑之路

之前做项目的时候作为小白的我在使用element-ui的弹框el-dialog的时候弹框里面插入的是一个组件,因为是组件的问题导致每次点击弹框的时候页面组件里面的值没有进行刷新。

其实简单的情况下v-if可以解决这个问题 但是这个时候弹框页面是组件,vue组件渲染之后再次点击需要刷新不然不会重新渲染页面(主要是新增和编辑页面都是同一个页面导致的)。这就让我很尴尬但是纠结了很久。其实解决方法很简单就是在子组件(弹框引入的组件)里面加上一个watch监听值的变化就可以了。

直接上代码吧 弹框:

子组件就是这里的 SolutionCalculationForm 只展示主要的watch部分了

watch: { 'solutionCalculationIds': function () { this.solutionParametersId = this.solutionCalculationIds; if (this.solutionParametersId)//编辑 { this.findSolutionParametersForEdit(this.solutionParametersId); } else//新增 { this.createSolutionParameters(); } } }, created() { // this.solutionCalculationId = this.$route.params.solutionCalculationId; this.solutionCalculationId = this.solutionCalculationIds; if (this.solutionCalculationId)//编辑 { this.findSolutionCalculationForEdit(this.solutionCalculationId); } else//新增 { this.createSolutionCalculation(); } },

这种情况主要是让数据双向绑定情况下,可以有新数据,或者重新获取一个空数据。主要是通过watch实现监听父组件传来的那个值。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3